package com.base.log
{
	import com.base.util.Utils;
	
	import flash.filesystem.File;
	import flash.filesystem.FileMode;
	import flash.filesystem.FileStream;

	public class Log
	{
		public function Log()
		{
			
		}
		
		private static var logFile:File;
		
		
		public static function log( ...params):void {
			trace( params );
			if( logFile == null ) logFile = new File( getLogFileUrl() );
			
			var fileStream:FileStream = new FileStream();
			fileStream.open( logFile , FileMode.APPEND );
			fileStream.writeMultiByte(Utils.dateToString( new Date())+ "\t"+params.toString()+"\r\n" , "UTF-8" );
			fileStream.close();
		}
		
		
		private static function getLogFileUrl():String {
			var path:String = flash.filesystem.File.applicationDirectory.nativePath+"\\log";
			var d:Date = new Date();
			var fileName:String = d.fullYear +""+(d.month+1)+""+d.date + ".log";
			return  path+"\\"+ fileName;
		}
		
		
		
	}
}